﻿    <script type="text/javascript">
        $(document).ready(function () {
            var p = new singlepage();
            p.c = "Way.Bus.WMS.XHY.Controllers.SellOutOrderController";
            p.applyTo = "t1";
            p.ishelp = false;
            p.onBeforeEdited = function (g, sender, index, row, ed) {
                if (row.STAY4 == "已确认") {
                    if (ed.target)
                        ed.target.setdisabled(true);
                }
            }
            p.onOpenWinShow = function (form, data, command) {
                form.onsearchforeign = function (box, obj) {
                    if (box.field == 'PORTNAME') {
                        obj.ColumnName = 'TPCODE';
                    }
                }
            }
            p.onCommandClick = function (command, form, item) {

                if (command == "edit") {
                    if (item.ISREVIEWED == true || item.ISSUBMITED == true) {
                        form.setdisabled(true);
                    }
                }
            }
            p.onForeigned = function (sender, fdata, rows) {
                if (fdata.tablename.toString() == "Acc_Bus_BusinessCommodity" && sender.field.toString() == "MATERIALCODE") {
                    var tt = p.datasource.post("VoliGetUnit", "MaterialsId=" + rows.ID + "");
                    if (tt != "") {
                        var row = sender.parent.selectrow();
                        var eb = sender.parent.geteditor("MATERIALPACKID");
                        eb.setValue(eb.target, tt, row);
                    }
                    //grid.load({ total: tt.length, rows: tt });
                }
                if (fdata.tablename.toString() == "Acc_WMS_OutNotice" && sender.field.toString() == "SOURCECODE") {
                    var aa = p.datasource.post("GetNoticeMaterials", "NoticeId1=" + fdata.filedvalue + "");
                    if (aa != "[]") {
                        var grid1 = sender.parent.griditems["Way.Bus.WMS.Model.StockOutOrderMaterials"];
                        grid1.clear();
                        grid1.insertRow(aa);
                    }
                    var tt = p.datasource.post("GetNoticeStayGrid", "NoticeId=" + fdata.filedvalue + "");
                    if (tt != "[]") {
                        var grid = sender.parent.griditems["Way.Bus.WMS.Model.StockOutNoticeMaterials"];

                        grid.clear();
                        grid.insertRow(tt);

                    }



                }
                if (fdata.tablename.toString() == "Acc_WMS_OutNotice" && sender.field.toString() == "SOURCECODE") {


                }
                if (fdata.tablename == "Acc_WMS_WareHouse" && sender.field == "DEPOTWBS") {
                    var eb = sender.parent.geteditor("PORTNAME");
                    rows[eb.target.foreign.displayname] = rows["TPCODE"]
                    rows[eb.target.field] = rows["TPID"];
                    eb.actions.setValue(eb.target, "", rows);
                    var eb2 = sender.parent.geteditor("BATCHNO");
                    var pici = eb2.actions.getValue(eb2.target);
                    if (pici == "") {
                        eb2.actions.setValue(eb2.target, rows["BATCHNO"]);
                    }
                    var eb1 = sender.parent.geteditor("NUM");
                    eb1.actions.setValue(eb1.target, rows["NUM"], rows[eb1.field]);

                    var ebTime = sender.parent.geteditor("REVIEWEDDATE");
                    var rowTime = ebTime.actions.getValue(ebTime.target);
                    ebTime.actions.setValue(ebTime.target, rows["STAY11"]);
                }
                if (fdata.tablename == "Acc_WMS_Ports" && sender.field == "PORTNAME") {
                    var eb = sender.parent.geteditor("DEPOTWBS");
                    rows[eb.target.foreign.displayname] = rows["HWCODE"]
                    rows[eb.target.field] = rows["HWID"];
                    eb.actions.setValue(eb.target, "", rows);
                    var eb2 = sender.parent.geteditor("BATCHNO");
                    var pici = eb2.actions.getValue(eb2.target);
                    if (pici == "") {
                        eb2.actions.setValue(eb2.target, rows["BATCHNO"]);
                    }
                    var eb1 = sender.parent.geteditor("NUM");
                    eb1.actions.setValue(eb1.target, rows["NUM"], rows[eb1.field]);
                    //                    var time = sender.parent.geteditor("REVIEWEDDATE");
                    //                    time.actions.setValue(time.target, rows["REVIEWEDDATE"], rows[eb1.field]);
                }
            }
            p.init();
        });

        function OpenWin(data) {
            window.open("Views/WMS/XHY/SaleList.aspx?ID=" + data.item.ID + "", "_black", "width=1100,height=600,left=200,top=200");
        }
      </script>
<div id="t1"></div>
